//引入fs模块
const fs = require('fs')

//封装promise函数
const p = new Promise(function(resolve,reject){
    fs.readFile('./resource/file.mda',(err,data)=>{
        if(err) reject(err)
        resolve(data)
    })
})

//调用promise的then方法
p.then(function(value){
    console.log(value.toString())
},function(reason){
    console.log(reason)
})